import fs from "fs";
import { localConfigName } from "../constants";
import getLocalConfig from "./getLocalConfig";
import initFolder from "./initFolder";

const initLocalConfig = async () => {
    if (!fs.existsSync(localConfigName)) {
        fs.writeFileSync(localConfigName, JSON.stringify({ 'download-folder': process.cwd() + '/download/' }, '\n', 4));
    }
    let { 'download-folder': downloadPath } = await getLocalConfig();
    initFolder(downloadPath);
}

export default initLocalConfig;